Skip to content

test(android): Add GradleTestKit tests for sentry.gradle.kts asset tasks - #6754

Open
antonis wants to merge 7 commits into
al/fix-gradle-modules-generated-assetsfrom
al/gradle-asset-tasks-tests
Open

antonis wants to merge 7 commits into
al/fix-gradle-modules-generated-assetsfrom
al/gradle-asset-tasks-tests

Conversation

@antonis

@antonis antonis commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Tests

📜 Description

Adds test for PRs #6751 and #6753

💡 Motivation and Context

Closes #6752

💚 How did you test it?

  • CI

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • test(android): Add GradleTestKit tests for sentry.gradle.kts asset tasks by antonis in #6754
  • fix(android): Generate modules.json into build folder instead of source tree by antonis in #6753
  • fix(ios): Fix Mac Catalyst linking the wrong Sentry.xcframework slice by antonis in #6758
  • chore(deps): bump the codeql-action group across 1 directory with 3 updates by dependabot in #6756
  • chore(deps): bump ruby/setup-ruby from 1.321.0 to 1.324.0 by dependabot in #6757
  • fix(android): Generate sentry.options.json into build folder instead of source tree by antonis in #6751
  • fix(core): Declare optional peer dependencies to resolve phantom imports under strict package managers by antonis in #6729
  • Add missing exports and update public API report by antonis in #6731
  • test(ios): Reenable Session Replay E2E test by antonis in #6737
  • fix(ios): Honor shutdownTimeout on iOS by antonis in #6749

🤖 This preview updates automatically when you update the PR.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 495.04 ms 560.02 ms 64.98 ms
Size 50.56 MiB 56.50 MiB 5.93 MiB

Baseline results on branch: al/fix-gradle-modules-generated-assets

Startup times

Revision Plain With Sentry Diff
3da007c+dirty 424.56 ms 448.54 ms 23.98 ms
38ab0b8+dirty 426.03 ms 446.65 ms 20.62 ms
1e3886c+dirty 421.49 ms 464.16 ms 42.67 ms
7a2d816+dirty 470.94 ms 515.62 ms 44.68 ms
3bacb46+dirty 423.54 ms 428.93 ms 5.39 ms

App size

Revision Plain With Sentry Diff
3da007c+dirty 50.56 MiB 56.50 MiB 5.93 MiB
38ab0b8+dirty 50.56 MiB 56.50 MiB 5.93 MiB
1e3886c+dirty 50.56 MiB 56.50 MiB 5.93 MiB
7a2d816+dirty 50.56 MiB 56.50 MiB 5.93 MiB
3bacb46+dirty 50.56 MiB 56.50 MiB 5.93 MiB

Previous results on branch: al/gradle-asset-tasks-tests

Startup times

Revision Plain With Sentry Diff
1a52662+dirty 471.36 ms 518.12 ms 46.76 ms
9945bc7+dirty 487.80 ms 540.44 ms 52.64 ms
e04bc70+dirty 431.27 ms 455.69 ms 24.42 ms
aa679e6+dirty 426.69 ms 455.90 ms 29.20 ms
f20cf41+dirty 426.83 ms 446.08 ms 19.25 ms

App size

Revision Plain With Sentry Diff
1a52662+dirty 50.56 MiB 56.50 MiB 5.93 MiB
9945bc7+dirty 50.56 MiB 56.50 MiB 5.93 MiB
e04bc70+dirty 50.56 MiB 56.50 MiB 5.93 MiB
aa679e6+dirty 50.56 MiB 56.50 MiB 5.93 MiB
f20cf41+dirty 50.56 MiB 56.50 MiB 5.93 MiB

@sentry

sentry Bot commented Sep 18, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.27.0 (107) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 413.15 ms 441.29 ms 28.13 ms
Size 50.56 MiB 56.50 MiB 5.93 MiB

Baseline results on branch: al/fix-gradle-modules-generated-assets

Startup times

Revision Plain With Sentry Diff
3da007c+dirty 429.00 ms 457.34 ms 28.34 ms
38ab0b8+dirty 417.88 ms 431.80 ms 13.92 ms
1e3886c+dirty 434.40 ms 470.29 ms 35.89 ms
7a2d816+dirty 433.18 ms 458.43 ms 25.25 ms
3bacb46+dirty 428.24 ms 459.82 ms 31.58 ms

App size

Revision Plain With Sentry Diff
3da007c+dirty 50.56 MiB 56.50 MiB 5.93 MiB
38ab0b8+dirty 50.56 MiB 56.50 MiB 5.93 MiB
1e3886c+dirty 50.56 MiB 56.50 MiB 5.93 MiB
7a2d816+dirty 50.56 MiB 56.50 MiB 5.93 MiB
3bacb46+dirty 50.56 MiB 56.50 MiB 5.93 MiB

Previous results on branch: al/gradle-asset-tasks-tests

Startup times

Revision Plain With Sentry Diff
1a52662+dirty 425.61 ms 440.60 ms 14.99 ms
9945bc7+dirty 447.71 ms 506.08 ms 58.37 ms
e04bc70+dirty 422.98 ms 441.69 ms 18.71 ms
aa679e6+dirty 452.06 ms 474.58 ms 22.52 ms
f20cf41+dirty 429.12 ms 447.57 ms 18.45 ms

App size

Revision Plain With Sentry Diff
1a52662+dirty 50.56 MiB 56.50 MiB 5.93 MiB
9945bc7+dirty 50.56 MiB 56.50 MiB 5.93 MiB
e04bc70+dirty 50.56 MiB 56.50 MiB 5.93 MiB
aa679e6+dirty 50.56 MiB 56.50 MiB 5.93 MiB
f20cf41+dirty 50.56 MiB 56.50 MiB 5.93 MiB

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 14b2a29. Configure here.

@antonis
antonis force-pushed the al/gradle-asset-tasks-tests branch from 14b2a29 to 6be74ae Compare September 21, 2026 13:51
@antonis
antonis force-pushed the al/fix-gradle-modules-generated-assets branch from 9d22855 to a2fcc04 Compare September 21, 2026 14:03
@antonis
antonis force-pushed the al/gradle-asset-tasks-tests branch 2 times, most recently from c89d8ba to 4367636 Compare September 21, 2026 14:30

@lucas-zimerman lucas-zimerman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

antonis and others added 5 commits September 22, 2026 09:08
Cover the generated-asset tasks introduced for issue #6750 (PRs #6751/#6753)
with functional tests that apply the real sentry.gradle.kts script plugin to a
minimal AGP fixture and drive the tasks through GradleTestKit:

- SentryOptionsTaskTest: plain copy, SENTRY_RELEASE override, opt-out via
  SENTRY_COPY_OPTIONS_FILE=false, and missing-source fallback.
- SentryModulesTaskTest: modules.json generated into build/ (never src/main/
  assets), UP-TO-DATE on rebuild, skipCollectModules opt-out, and missing
  source map fallback.

Runs on the existing RNSentryAndroidTester testDebugUnitTest job, so no new CI
infrastructure is required.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…pendency

Two-build-type fixture (`release` + `qaRelease`) proving `lintQaRelease` does
not depend on the `release` variant's modules task. Verified red-capable: it
fails against the old `it.name.contains(variantCapitalized)` substring match and
passes with the token-boundary scoping.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Pass a SENTRY_*-scrubbed environment to GradleRunner in both asset-task test
classes so the assertions depend only on the fixture and each test's explicit
env, not on SENTRY_RELEASE/ENVIRONMENT/DIST/COPY_OPTIONS_FILE a developer may
have exported locally.

Also extend the variant-scoping regression to assert the non-`lint*`-prefixed
`updateLintBaselineQaRelease` is likewise not wired to the release modules task,
and document that `lintRelease` is a non-vacuity control (in this fixture lint
depends on the modules task only through the explicit wiring).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Guards the lint-family matcher against over-binding: a `ktlint*` task (from the
ktlint Gradle plugin) carries a lowercase `lint` mid-name and the variant name
but is not an AGP lint task, so it must not depend on CollectModulesTask and
pull in the JS bundler. Fails against a case-insensitive `lint` substring match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a GradleTestKit regression test asserting the modules task stays
UP-TO-DATE — and its modules.json is preserved, not emptied — when the
source map it reads is deleted (as the upload cleanup does) and the bundle is
unchanged. The bundle stub now also writes the --bundle-output file (the
task's stable fingerprint) and can declare it as an output so the bundle task
goes up-to-date on rerun, reproducing the real bundle task that does not track
the forced source map as an output.

Red against a source-map-fingerprinted task (re-runs, finds no map, packages
an empty assets dir); green once the fingerprint is the bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@antonis
antonis force-pushed the al/gradle-asset-tasks-tests branch from 4367636 to 5217d5e Compare September 22, 2026 07:08
GenerateSentryOptionsTask.generate() parses the source as JSON before applying
SENTRY_ENVIRONMENT/RELEASE/DIST overrides, and on a parse failure logs a warning
and copies the source verbatim rather than failing the build. That catch branch
was untested (Warden flagged the coverage gap on #6751).

Add a case with an override set and a malformed source, asserting the task
succeeds and the output matches the source byte-for-byte — verbatim equality
proves the fallback ran, since a successful parse would re-serialize the JSON.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
File(projectDir, "build.gradle").writeText(
"""
plugins {
id 'com.android.application' version '8.3.2'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it actually have to be hardcoded here (and below as well)? If we bump AGP, the fixtures will keep testing 8.3.2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍 Fixed in 9a2fcea

]
android {
namespace 'io.sentry.fixture'
compileSdk 34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compileSdk 34 in the fixture while the host project pins 33

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with 9a2fcea


val bundleFile = File(projectDir, "build/generated/assets/react/release/index.android.bundle")
val sourcemapFile = File(projectDir, "build/generated/sourcemaps/react/release/index.android.bundle.map")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both files (this and SentryOptionsTaskTest.kt) have identical shared code (settings.gradle, local.properties, manifest) that can be extracted to some common base or helper

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with 9a2fcea

Address review feedback on the GradleTestKit fixtures:

- Stop hardcoding AGP 8.3.2 and compileSdk 34 in the fixtures. The host build
  now injects its own AGP version (com.android.Version) and compileSdk as system
  properties, and the fixtures read them, so bumping the host no longer leaves
  the fixtures silently testing a stale toolchain. This also fixes the fixture
  pinning compileSdk 34 while the host is on 33.
- Extract the duplicated scaffolding (settings.gradle, local.properties, stub
  manifest, path escaping, SENTRY_* env scrubbing, system-property reads) from
  both test classes into a shared BaseSentryGradleTest base class.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@antonis
antonis requested a review from alwx September 22, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants